import {createStore, useStore as baseUseStore, Store} from "vuex";
import {InjectionKey} from "vue";
import global from "./moudle/global";
import recommend from "./moudle/discover/recommend";
import playlist from "./moudle/playlist";
import window from "./moudle/window";
import login from "./moudle/login";

export interface State {
    global: {
        list: any;
        artistToplist: any;
        rewardToplist: any;
        soaringList: any
        newSongList: any;
        OriginalList: any
    };
    recommend: {
        banners: any
        IncompletePersonalized: any
        recommendedListOfTheDay: any
        newAlbumList: any
    };
    playlist: {
        playlist: []
    };
    window: {
        windowHeight: number
        windowPageYOffset: number
    };
    login: {
        isShowLoginDialog: boolean
        userDetail: any
        isLogin: boolean
    };

}

export const key: InjectionKey<Store<State>> = Symbol();
export const store = createStore({
    // 公共模板直接在这里展开就可以
    modules: {
        global,
        recommend,
        playlist,
        window,
        login,
    },
});

export function useStore() {
    return baseUseStore(key);
}
